<?php 
Class formsController extends appController
{

	public function submit()
	{
		$result=array('error'=>1,'content'=>'');
		$info['name']=isset($_POST['name'])?hy_check($_POST['name'],'ur'):'';
		$info['email']=isset($_POST['email'])?hy_check($_POST['email'],'e'):'';
		$info['phone']=isset($_POST['phone'])?hy_check($_POST['phone'],'n'):'';
		$info['content']=isset($_POST['content'])?hy_substr($_POST['content'],'255'):'';
		$info['ip']=hy_getIP();
		$info['created']=$_SERVER['REQUEST_TIME'];
		if($info['name']=='#@_error')
		{
			$result['content']='名字格式错误';
			print_r(json_encode($result));
			exit;
		}
		if($info['email']=='#@_error')
		{
			$result['content']='邮件格式错误';
			print_r(json_encode($result));
			exit;
		}
		if($info['phone']=='#@_error')
		{
			$result['content']='电话格式错误';
			print_r(json_encode($result));
			exit;
		}
		$check=Model('forms')->check_ip(array('ip'=>$info['ip'],'table'=>'forms_log_1'));
		if(!$check)
		{
			$result['content']='你提交得太频繁了';
			print_r(json_encode($result));
			exit;
		}
		$res=Model('forms')->insert($info,'forms_log_1');
		
		
		if($res)
		{
			$result['error']=0;
			$result['content']='添加成功';
		}
		else
		{
			$result['content']='系统繁忙';
		}
		print_r(json_encode($result));
		exit;
	}
	
}